<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Login extends XX_Controller
{

    function __construct()
    {
        parent::__construct();
        $this->load->model('login_model', 'loginMod');
    }

    /**
     *
     */
    public function index()
    {
        $this->load->helper('language');
        $this->load->view('index');
    }

    /**
     * 登录
     */
    public function do_login()
    {
        $username = $this->input->post('username', TRUE);
        $pwd = $this->input->post('pwd', TRUE);

        $ret = $this->loginMod->do_login($username, $pwd);

        if ($ret->get_code() === 0) { //登录成功
            //加载session类
            $this->load->library('session');

            $user = $ret->get_data();
            $sesion_data = array(
                'user_code' => $user['user_code'],
//                'role' =>  $user['user_role'],
                'logged_in' => TRUE
            );

            $this->session->set_userdata($sesion_data);

            $ret->set_result($user);//将用户信息传给view
        }
        $this->outputJson($ret->get_result(), true);
    }

    /**
     * 登出
     */
    public function do_logout()
    {

    }
}
/* End of file login.php */
/* Location: ./application/controllers/login.php */